package com.xuecheng.content.controller;

import com.xuecheng.api.content.model.dto.CoursePubDTO;
import com.xuecheng.common.domain.response.RestResponse;
import com.xuecheng.content.service.CoursePubService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 课程发布 前端控制器
 * </p>
 *
 * @author itcast
 */
@Slf4j
@RestController
public class CoursePubController {

    @Autowired
    private CoursePubService coursePubService;


    /**
     * 根据课程发布id 获取课程发布对象信息
     *
     * @param coursePubId 课程发布id
     */
    @GetMapping("l/course-pub/{coursePubId}")
    RestResponse<CoursePubDTO> getCoursePubById(@PathVariable(value = "coursePubId") Long coursePubId) {
        return coursePubService.getCoursePubById(coursePubId);
    }

    @GetMapping("l/coursePubByCompanyId/{companyId}")
    RestResponse<List<CoursePubDTO>> getCoursePubByCompanyId(@PathVariable(value = "companyId") Long companyId) {

        return coursePubService.getCoursePubByCompanyId(companyId);
    }

    /**
     * <p>
     * 根据课程id获取课程发布信息
     * </p>
     *
     * @param courseId 课程id
     * @return RestResponse<CoursePubDTO>
     */
    @GetMapping("l/course/pub/{courseId}")
    RestResponse<CoursePubDTO> getCoursePubByCourseId(@PathVariable Long courseId) {
        return coursePubService.getCoursePubByCourseId(courseId);
    }

}
